﻿<!doctype html>
<html lang="en">
<head>
    <script type="text/javascript" src="js/jquery-2.1.3.js"></script>
    <script type="text/javascript" src="js/highstock.js"></script>
    <script type="text/javascript" src="js/modules/exporting.js"></script>
    <script type="text/javascript" src="js/chu/chu_common.js"></script>
    <script>
        $(function () {

            //取分析时间
            var init = true;
            if (init) {
                var url = "/rest/rest/analyzevalue1";
                //$.ajaxSetup({ async: false });
                $.getJSON(url, function (data) {
                    var d = data.split('-');
                    $("#oldselect").empty();
                    for(var i=d.length-1;i>=0;i--)
                    {
                        $("#oldselect ").append("<option>" + d[i] + "</option>");
                    }
                });
                init = false;
            }

            var end = new Date();
            var tag = chu_common.formatdate(end);
            var old = $("#oldselect  option:selected").text();
            var url_default = "/web/analyze.html?tag=" + tag + "&level=0&old=" + old + "&daybefore=0";
            var level = $("#levelselect  option:selected").text();

            function ImageExist(url) {
                $.ajaxSetup({ async: false });
                $.ajax({
                    url: url,
                    type: 'HEAD',
                    error: function () {
                        return false;
                    },
                    success: function () {
                        return true;
                    }
                });
            };


            $("#day1").html("<iframe src='" + url_default + "' width=1200 height=1350 frameborder=0 ></iframe>");


            $("#oldselect").change(function () {
                $("#IndustrySelect").val("");
                $("#LocationSelect").val("");
                //$("#day1").remove();
                var old = $("#oldselect  option:selected").text();
                
                var industry = $("#IndustrySelect  option:selected").text();
                var location = $("#LocationSelect  option:selected").text();
                //alert("/web/analyze.html?start=" + start1 + "&end=" + format(end) + "&level=1");
                var url_1 = "/web/analyze.html?old=" + old + "&level=" + level + "&tag=" + tag + "&daybefore=0&industry=" + industry + "&location=" + location;
                $("#day1").html("<iframe src='" + url_1 + "' width=1200 height=1500 frameborder=0></iframe>");
            });



            var url = "/rest/rest/info/all?type=I";
            //$.ajaxSetup({ async: false });
            $.getJSON(url, function (data) {
                $("#IndustrySelect").empty();
                $("#IndustrySelect").append("<option></option>");
                for (var i in data) {
                    $("#IndustrySelect").append("<option>" + data[i] + "</option>");
                }
            });

            var url_1 = "/rest/rest/info/all?type=L";
            //$.ajaxSetup({ async: false });
            $.getJSON(url_1, function (data) {
                $("#LocationSelect").empty();
                $("#LocationSelect").append("<option></option>");
                for (var i in data) {
                    $("#LocationSelect").append("<option>" + data[i] + "</option>");
                }
            });

            $("#LocationSelect").change(function () {
                $("#IndustrySelect").val("");
                //$("#day1").remove();
                var old = $("#oldselect  option:selected").text();
                var level = $("#levelselect  option:selected").text();
                var location = $("#LocationSelect  option:selected").text();
                var u = "/web/temp/analyze_" + old + "_" + location + ".html";
                if (ImageExist(u)) {
                    var url_1 = u;
                } else{
                    var url_1 = "/web/analyze.html?old=" + old + "&level=" + level + "&tag=" + tag + "&daybefore=0&&location=" + location;
                }
                //alert("/web/analyze.html?start=" + start1 + "&end=" + format(end) + "&level=1");
               // var url_1 = "/web/analyze.html?old=" + old + "&level=" + level + "&tag=" + tag + "&daybefore=0&&location=" + location;
                
                $("#day1").html("<iframe src='" + url_1 + "' width=1200 height=1500 frameborder=0></iframe>");
            });

            $("#IndustrySelect").change(function () {
                $("#LocationSelect").val("");
                //$("#day1").remove();
                var old = $("#oldselect  option:selected").text();
                var level = $("#levelselect  option:selected").text();
                var industry = $("#IndustrySelect  option:selected").text();
                //alert("/web/analyze.html?start=" + start1 + "&end=" + format(end) + "&level=1");
                var url_1 = "/web/analyze.html?old=" + old + "&level=" + level + "&tag=" + tag + "&daybefore=0&industry=" + industry;
                $("#day1").html("<iframe src='" + url_1 + "' width=1200 height=1500 frameborder=0></iframe>");
            });

            $("#TypeSelect").change(function () {
                //$("#LocationSelect").val("");
                //$("#IndustrySelect").val("");
                //$("#day1").remove();
                var old = $("#oldselect  option:selected").text();
                var level = $("#levelselect  option:selected").text();
                var type = $("#TypeSelect  option:selected").val();
                //alert("/web/analyze.html?start=" + start1 + "&end=" + format(end) + "&level=1");
                var url_1 = "/web/analyze.html?old=" + old + "&level=" + level + "&tag=" + tag + "&daybefore=0&type=" + type;
                $("#day1").html("<iframe src='" + url_1 + "' width=1200 height=1500 frameborder=0></iframe>");
            });

            //30日前
            //$("#query1").click(function () {
            //    //$("#day1").remove();
            //    var old = $("#oldselect  option:selected").text();
            //    var level = $("#levelselect  option:selected").text();
            //    var industry = $("#IndustrySelect  option:selected").text();
            //    var location = $("#LocationSelect  option:selected").text();
            //    //alert("/web/analyze.html?start=" + start1 + "&end=" + format(end) + "&level=1");
            //    var url_1 = "/web/analyze.html?old=" + old + "&level=" + level + "&tag=" + tag + "&daybefore=0&industry=" + industry+"&location="+location;
            //    $("#day1").html("<iframe src='" + url_1 + "' width=1200 height=1500></iframe>");
            //});
        });
    </script>
</head>
<body>

<!--    <div>-->
            <select id="oldselect"></select>月前
            <select id="levelselect"> <option>0</option></select>
            <!--<input type="button" id="query" value="当日计算" />-->
<!--            <input type="button" id="query1" value="30日前计算" />-->
            行业:<select id="IndustrySelect" ><option>0</option></select> 
            区域:<select id="LocationSelect"><option>0</option></select>
			类型:<select id="TypeSelect">
                <option></option>
                <option value="CYB">创业板</option>
				<option value="XPG">小盘股（小于1亿）</option>
                <option value="ZXB">中小板（小于3亿）</option>
                <option value="ZB">大盘股（大于20亿）</option>
                <option value="SH">上海</option>
                <option value="SZ">深圳</option>

			   </select>
<!--    </div>-->
    <div id="Content">
        <div id="day1"></div>
    </div>
    <div class="Clear"></div>
    <div id="Footer">Footer</div>
</div>


</body>
</html>